<?php
if(!defined('DEDEINC')) exit("Request Error!");

require_once(LIB.'/datalistcp.class.php');
/**
 *问答模块 注册后台控制器
 * by zsh
 */

class contact extends Control{

    function contact(){
        parent::__construct();
        $this->style = 'admin';
        $this->mcollegeinfo_detail = $this->Model('mcollegeinfo_detail');
    }

    function ac_index(){
        $data = $this->mcollegeinfo_detail->detail_get_list("#@__contact","1");
        $this->SetVar("data",$data);
        $this->SetTemplate('contact.htm');      //载入模板
        $this->Display();
    }


    function ac_delete(){
        $id = request("id","");
        $this->mcollegeinfo_detail->detail_query("delete from #@__contact where id=".$id);
        showMsg("删除成功！","?wenda&ct=contact");
    }

    function ac_edit(){
        $key = request("key","");
        $value = request("value","");
        $this->mcollegeinfo_detail->detail_query("delete from #@__contact where 1"); // 先清空表 再插入新数据
        foreach ($key as $k => $v) {
            $tmp_key = trim($key[$k]);
            $tmp_value = trim($value[$k]);
            if(empty($tmp_key) && empty($tmp_value)){ // 若键值同时为空则不插入数据
                continue;
            }else{
                $this->mcollegeinfo_detail->detail_query('insert into #@__contact (`key`,`value`) values("' . trim($key[$k]) . '","' . trim($value[$k]) .'")');
            }
        }
        showMsg("提交成功!","?wenda&ct=contact");
    }
}
?>